\begin{Program}
{\small 
\begin{verbatim}
let make_constructors ctx ty =
    let make_abs (name,ty) =  
        "lam " ^ name ^ " : " ^ (string_of_type ctx ty Alpha) ^ "." in
    
    match ty with
    |TyArr (ty1,ty2) when is_data_type ctx ty1 ->
        (* inner_term (below) corresponds to the term	 *)
        (* (x [ty2]) in which x is a variable of type	 *)
        (* ty1                                           *)
        let inner_term = TmTApp((TmVar 0), (typeShift 1 ty2)) in
        let inner_ctx, varName1 =  fresh_fvar ctx ty1 in
        let cons_types = 
            get_constructor_arguments ctx ty2 
            (typeShift (-1) (typeof inner_ctx inner_term)) in
		
        (* (typeof (x [ty2])) is a constructor for [ty2] *)
        (* each of the constructor arguments is          *)
        (* associated with a new function name           *)
        (* name variable                                 *)
        let names_types = (List.map (fun ty -> fresh_lcid( ),ty) cons_types) in
		
        (* which allows the string form construction of  *)
        (* the common inner-bodies for all the           *)
        (* constructors                                  *)
        let final_inner_term = ref (string_of_term inner_ctx inner_term Alpha) in
        List.iter 
            (fun (name, _) -> final_inner_term := !final_inner_term ^ " " ^ name) 
            names_types;
        final_inner_term := make_abs(varName1,ty1)^ !final_inner_term;
		
        (* All the permutations of constructors can now *)
        (* be constructed  in their string form         *)		
        let constructors = ref [] in
        List.iter (fun name_type_lst ->
            constructors := 		
                (String.concat "" 
                    ((List.map make_abs name_type_lst) @ [!final_inner_term]))::
                !constructors)  (permutations names_types);
		
        (* and returned in their term representation    *)		
        List.map (fun str -> ter(parse_string str ctx))	 !constructors
	
    |_->failwith "non constructible type"
\end{verbatim}}
\caption{The $make\_constructors$ function}
\end{Program}